﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using EvolutionBaseTypes;
using EvolutionBaseTypes.Interfaces;


namespace Evolution.Structure.Globe
{
    public class Technology : ILoadable<Technology>
    {
        public string Name { get; set; }
        public int ResearchCosts { get; set; }
        public List<Technology> Predecessors { get; private set; }

        public Technology()
        {
            Predecessors = new List<Technology>();
        }
        public Technology(string name, int researchCosts, List<Technology> predecessors)
        {
            this.Name = name;
            this.ResearchCosts = researchCosts;
            this.Predecessors = predecessors;
        }

        public Technology LoadData(LoaderFactory<Technology> factory)
        {
            try
            {
                Technology temp  = factory.Load();
                this.Name = temp.Name;
                this.ResearchCosts = temp.ResearchCosts;
                this.Predecessors = Predecessors;
                return this;
            }
            catch (Exception) { return null; }
        }
        
        public override string ToString()
        {
            return Name;
        }
    }
}
